#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point()
    //初始化列表中对数据成员的初始化是严格意义上的初始化
    : _ix(0)//int _ix = 0;
    , _iy(0)
    {
        //在函数体中对数据成员进行”初始化“
        //并非是严格意义上的初始化
        //其本质是赋值
        //int _ix;
        //_ix = 0;
        /* _ix = 0; */
        /* _iy = 0; */
        cout << "Point()" << endl;
    }

    //数据成员的初始化顺序与其声明顺序一致
    //与它们在初始化列表中的顺序无关
    //与形参顺序也无关
    Point(int x,int y = 1)
    : _ix(x)//int _ix = x;
    , _iy(y)
    {
        /* _ix = x; */
        /* _iy = y; */
        cout << "Point(int,int)" << endl;
    }

    void print(){
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl;
    }
    
private:
    //C++11允许在声明时进行初始化（默认值性质）
    //通常是在定义类时不定义构造函数
    //又希望让数据成员有确定的初始化
    /* int _ix = 10; */
    /* int _iy = 10; */
    
    //数据成员的声明
    int _ix;
    int _iy;
};

void test0(){
    int num;
    
    cout << sizeof(Point) << endl;

    Point pt2(1,2);
    pt2.print();

    Point pt3(4,8);
    pt3.print();

    Point pt4(10);
    pt4.print();

    Point pt;
    pt.print();
}

int main(void){
    test0();
    return 0;
}
